home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene 96
/
Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso
/
misc
/
coding
/
kmagv3
/
waveexam.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-01-11
|
3KB
|
88 lines
{WAVEEXAM.PAS / EXAMPLE FOR A WAVES EFFECT}
{WRITING BY THE KING IN 01/06/96 }
Uses KMagUnit;
Const
Waves = 3; {Number of waves}
SinWaves = 5; {Depth of waves}
Var
Y,T,T1 : Integer;
SinT,CosT:Array[0..360] Of ShortInt; {Sin Cosin tables}
Pic : PicTypeP; {Picture}
Pal : PalType; {Palette}
{-------------------------------------------------}
{ Make a Sin/Cos Tables of Shortint }
{-------------------------------------------------}
Procedure MakeSinCos;
Var
T:Integer;
Begin
For T:=0 To 360 Do
Begin
SinT[T]:=Round(Sin(T*Pi/180)*127);
CosT[T]:=Round(Cos(T*Pi/180)*127);
End;
End;
{Paint a vertrical line on the Y}
Procedure VLine(Y:Integer;Col:Byte);Assembler;
Asm
Mov Ax,0a000h {Ax = screen segment}
Mov Es,Ax {Es = Ax}
Mov Ax,320 {Ax = 320}
Mul Y {Ax = 320 * Y}
Mov Di,Ax {Di = Ax}
Mov Al,Col {Al = Col}
Mov Ah,Col {Ah = Col}
Mov Cx,160 {Cx = 160}
Rep StoSw {[Es:Di] = Al;[Es:Di+1] = Ah;Inc Di,2}
End;
{Draw one line from Where Y1 to Where1 Y}
Procedure DrawVLine(Y,Y1:Integer;Var Where,Where1);Assembler;
Asm
Cmp Y1,199 {Checking Ranges On Y1}
Ja @Exit
Cmp Y,199 {Checking Ranges On Y}
Ja @Exit
Push Ds {Saving DS}
Lds Si,Where {[Ds:Si] = Where}
Mov Ax,320 {Ax = 320}
Mul Y {Ax = Y * 320}
Add Si,Ax {Si = Ax}
Les Di,Where1 {[Es:Di] = Where1}
Mov Ax,320 {Ax = 320}
Mul Y1 {Ax = Y1 * 320}
Add Di,Ax {Di = Ax}
Mov Cx,160 {Cx = 160}
Rep MovSw {[Es:Di] = [Ds:Si];Inc Di,2;Inc Si,2;*320}
Pop Ds {Restore Ds}
@Exit:
End;
Begin
{Set Mode}
New(Pic);
MakeSinCos;
SetMode;
T:=0;
T1:= 0;
{Load Picture}
LoadCel('..\sea.Cel',Pic^,Pal);
{Put Pal}
ShowPal(Pal);
VLine(9,54);
VLine(181,54);
Repeat
For Y:=10 To 180 Do
Begin
T:=T+Waves;
T1 := (SinT[T mod 360]*SinWaves) Div 128;
DrawVLine(Y+T1,Y,Pic^,Mem[$a000:0000]);
End;
T:=T - 170*Waves;
Until(Port[$60]=1);
End.